package com.android.volley.http;

import java.util.Comparator;
import java.util.Objects;

public class FormBodyPart {

    private final String mName;
    private final ContentBody mBody;

    FormBodyPart(final String name, final ContentBody body) {
        this.mName = Objects.requireNonNull(name);
        this.mBody = Objects.requireNonNull(body);
    }

    public String getName() {
        return this.mName;
    }

    public ContentBody getBody() {
        return this.mBody;
    }

    public static class FormBodyComparator implements Comparator<FormBodyPart> {
        @Override
        public int compare(FormBodyPart arg0, FormBodyPart arg1) {
            int weight0 = arg0.getBody() instanceof BinaryBody ? 2 : 1;
            int weight1 = arg1.getBody() instanceof BinaryBody ? 2 : 1;
            return weight0 - weight1;
        }
    }
}
